<?php
//Start session
	@session_start();
	
	//Include database connection details
	require_once('inc/config.inc');
	//Connect to mysql server
	$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
	if(!$link) {
		die('Failed to connect to server: ' . mysql_error());
	}
	if (isset($_POST['submit'])){
	//Select database
	$db = mysql_select_db(DB_DATABASE);
	if(!$db) {
		die("Unable to select database");
	}
	$query =  mysql_query("UPDATE perm_members set firstname='".$_POST['firstname']."', lastname='".$_POST['lastname']."'
			  , email='".$_POST['email']."', role='".$_POST['role']."' WHERE id = '".$_POST['user_id']."'");
	if($query){
		header("Location: ../admin/index.php?update_user=success");
	}
	else{
		header("Location: ../admin/index.php?update_user=fail");
	}
	}
else {
	echo "Please Submit the form first.";
}
	?>